package com.jilujia.domain.user.repository;

import java.util.List;

import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

import com.jilujia.domain.user.User;
import com.jilujia.framework.domain.JpaBusinessRepository;

@Repository
@Transactional(readOnly = true)
public interface UserRepository extends JpaBusinessRepository<Long, User> {

	@Query("select u from User u where u.username = :username")
	User findUserByUsername(@Param("username") String username);

	@Query("select u from User u where u.nickname = :nickname")
	User findUserByNickname(@Param("nickname") String nickname);

	@Query("select u from User u where u.confirmtoken = :confirmtoken and u.active=false")
	User findUserByToken(@Param("confirmtoken") String confirmtoken);

	@Query("select u from User u")
	public List<User> findTop10Users();
}
